
// Copyright (c) 2022 NetEase, Inc. All rights reserved.
// Use of this source code is governed by a MIT license that can be
// found in the LICENSE file.

import NECommonKit
import NIMSDK
import UIKit

@objcMembers
open class TeamAnnouncementEditViewController: NEBaseTeamAnnouncementEditViewController {
    override open func setupUI() {
        super.setupUI()
        
        navigationView.backgroundColor = .white
        
        view.backgroundColor = .normalTeamBackColor
        navigationView.backgroundColor = .normalTeamBackColor
        navigationController?.navigationBar.backgroundColor = .normalTeamBackColor
        navigationView.moreButton.setTitleColor(.normalTeamOrangeColor, for: .normal)
        
        NSLayoutConstraint.activate([
            infoBackView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 0),
            infoBackView.topAnchor.constraint(equalTo: view.topAnchor, constant: 0 + NEConstant.navigationAndStatusHeight),
            infoBackView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -0),
            infoBackView.heightAnchor.constraint(equalToConstant: 72),
        ])
        
        NSLayoutConstraint.activate([
            headerView.leftAnchor.constraint(equalTo: infoBackView.leftAnchor, constant: kScreenInterval),
            headerView.centerYAnchor.constraint(equalTo: infoBackView.centerYAnchor),
            headerView.widthAnchor.constraint(equalToConstant: 40),
            headerView.heightAnchor.constraint(equalToConstant: 40),
        ])
        
        NSLayoutConstraint.activate([
            nameLabel.leftAnchor.constraint(equalTo: headerView.rightAnchor, constant: 12),
            nameLabel.rightAnchor.constraint(equalTo: infoBackView.rightAnchor, constant: -kScreenInterval),
            nameLabel.topAnchor.constraint(equalTo: headerView.topAnchor, constant: 2),
            nameLabel.heightAnchor.constraint(equalToConstant: 22),
        ])
        
        NSLayoutConstraint.activate([
            roleLabel.leftAnchor.constraint(equalTo: nameLabel.leftAnchor),
            roleLabel.rightAnchor.constraint(equalTo: nameLabel.rightAnchor),
            roleLabel.bottomAnchor.constraint(equalTo: headerView.bottomAnchor, constant: 0),
            roleLabel.heightAnchor.constraint(equalToConstant: 18),
        ])
        
        NSLayoutConstraint.activate([
            timeLabel.leftAnchor.constraint(equalTo: roleLabel.leftAnchor),
            timeLabel.rightAnchor.constraint(equalTo: roleLabel.rightAnchor),
            timeLabel.bottomAnchor.constraint(equalTo: roleLabel.bottomAnchor),
            timeLabel.heightAnchor.constraint(equalToConstant: 18),
        ])
        
        backView.layer.cornerRadius = 0.0
        NSLayoutConstraint.activate([
            backView.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 0),
            backView.topAnchor.constraint(equalTo: infoBackView.bottomAnchor, constant: 0),
            backView.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -0),
            backView.heightAnchor.constraint(equalToConstant: 300),
        ])
        
        NSLayoutConstraint.activate([
            textView.leftAnchor.constraint(equalTo: backView.leftAnchor, constant: 12.0),
            textView.rightAnchor.constraint(equalTo: backView.rightAnchor, constant: -32.0),
            textView.topAnchor.constraint(equalTo: backView.topAnchor, constant: 12.0),
            textView.heightAnchor.constraint(equalToConstant: 250),
        ])
        
        NSLayoutConstraint.activate([
            clearButton.rightAnchor.constraint(equalTo: backView.rightAnchor, constant: -12),
            clearButton.bottomAnchor.constraint(equalTo: countLabel.topAnchor, constant: -6),
            clearButton.widthAnchor.constraint(equalToConstant: 16),
            clearButton.heightAnchor.constraint(equalToConstant: 16),
        ])
    }
}
